package com.control.qct.businesssteward.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.activity.ChargeBackActivity;
import com.control.qct.businesssteward.base.BaseFragment;
import com.control.qct.businesssteward.utils.DateSelectUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 侧滑菜单--(退单) 订单查询
 * Created by Administrator on 2018/1/27 0027.
 */

public class ChargebackSearchOrderFragment extends BaseFragment {
    @BindView(R.id.rb_according_order_code_search)
    RadioButton mRbAccordingOrderCodeSearch;
    @BindView(R.id.rb_according_date_search)
    RadioButton mRbAccordingDateSearch;
    @BindView(R.id.rg_search_style)
    RadioGroup mRgSearchStyle;
    @BindView(R.id.et_order_code_search)
    EditText mEtOrderCodeSearch;
    @BindView(R.id.tv_start_date)
    TextView mTvStartDate;
    @BindView(R.id.tv_end_date)
    TextView mTvEndDate;
    @BindView(R.id.ll_date_style)
    LinearLayout mLlDateStyle;
    @BindView(R.id.tv_cancel)
    TextView mTvCancel;
    @BindView(R.id.tv_sure)
    TextView mTvSure;

    private ChargeBackActivity mChargeBackActivity;

    @Override
    protected View initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
            savedInstanceState) {
        return inflater.inflate(R.layout.fragment_chargeback_search_order, container, false);
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.mChargeBackActivity = (ChargeBackActivity) context;
    }

    @Override
    protected void initView(View view) {
        mRbAccordingOrderCodeSearch.setChecked(true);
        mRgSearchStyle.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
                switch (checkId) {
                    case R.id.rb_according_order_code_search:
                        mEtOrderCodeSearch.setVisibility(View.VISIBLE);
                        mLlDateStyle.setVisibility(View.GONE);
                        break;
                    case R.id.rb_according_date_search:
                        mEtOrderCodeSearch.setVisibility(View.GONE);
                        mLlDateStyle.setVisibility(View.VISIBLE);
                        break;
                }
            }
        });
    }

    @OnClick({R.id.tv_start_date, R.id.tv_end_date, R.id.tv_cancel, R.id.tv_sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_start_date:
                DateSelectUtils.getInstance(activity).setAccountDateSelectPop(activity,mTvStartDate);
                break;
            case R.id.tv_end_date:
                DateSelectUtils.getInstance(activity).setAccountDateSelectPop(activity,mTvEndDate);
                break;
            case R.id.tv_cancel:
                mChargeBackActivity.mDlMenu.closeDrawers();
                break;
            case R.id.tv_sure:
                mChargeBackActivity.mDlMenu.closeDrawers();
                break;
        }
    }
}
